﻿using B.S.DataBase.MyProject.Domain.Sales;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.E.ERP.Read.API.Applicantions.Command.ProcurementsCommand;
using T.E.ERP.Read.API.Applicantions.Command.SalesCommand;
using T.E.ERP.Read.API.Dtos.Dtos;

namespace T.E.ERP.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SalesController : ControllerBase
    {
        private readonly IMediator mediator;
        public SalesController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 单据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<DeliveryDTO>>> GetDelivery([FromQuery]GetDeliveryNoticeCommand request)
        {
            return mediator.Send(request);
        }




        /// <summary>
        /// 查询退货通知单（所有数据）
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<return_notice_mainDtos>>> Getreturn_notice_mainALL([FromQuery] return_notice_mainQueryCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 查询退货通知单（详细数据）
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<return_notice_main>>> Getreturn_notice_main([FromQuery] Getreturn_notice_mainCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 查询退货通知单（反填）
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public  Task<APIResult<List<Fanreturn_notice_mainDtos>>> FanTianreturn_notice_main([FromQuery] FanTianreturn_notice_mainCommand command)
        {
            return  mediator.Send(command);
        }




        /// <summary>
        /// 明细
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<DeliveryNotice>>> GetOneDelivery([FromQuery]GetOneDeliveryCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 反填-根据单据编码获取整个发货通知单内容
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<DeliveryDTO>>> GetDeliveAllById([FromQuery] GetDeliveryNoticeByIdCommand request)
        {
            return mediator.Send(request);
        }
    }
}
